'use strict';

angular.module('biblioApp')
    .service('Listing', ['$http', function Listing($http) {
    return {
        getListing:function (phrase, limit, page) {
            var params = {
                "phrase":phrase,
                "limit":limit,
                "page":page
            };
            return $http({ method:'GET', url:'http://biblio.homenet' +
                "/search.php",
                params:params, cached:false, withCredentials:false})
                .success(function (data, status) {
                    return data;
                }).error(function (data, status) {
                    alert('Error');
                });
        },
        getBookById:function (id) {
            var params = {
                "id":id
            };
            return $http({ method:'GET', url:'http://biblio.homenet' +
                "/search.php",
                params:params, cached:false, withCredentials:false})
                .success(function (data, status) {
                    return data;
                }).error(function (data, status) {
                    alert('Error');
                });
        }
    }
}]);
